/**
 */
package DentalClinicEMF.clinic.impl;

import DentalClinicEMF.clinic.ClinicPackage;
import DentalClinicEMF.clinic.Product;
import DentalClinicEMF.clinic.Service;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Service</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link DentalClinicEMF.clinic.impl.ServiceImpl#getName <em>Name</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ServiceImpl#getBaseCost <em>Base Cost</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ServiceImpl#getTimeSlotsRequired <em>Time Slots Required</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ServiceImpl#getProductsRequired <em>Products Required</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ServiceImpl extends MinimalEObjectImpl.Container implements Service {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getBaseCost() <em>Base Cost</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBaseCost()
	 * @generated
	 * @ordered
	 */
	protected static final int BASE_COST_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getBaseCost() <em>Base Cost</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBaseCost()
	 * @generated
	 * @ordered
	 */
	protected int baseCost = BASE_COST_EDEFAULT;

	/**
	 * The default value of the '{@link #getTimeSlotsRequired() <em>Time Slots Required</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimeSlotsRequired()
	 * @generated
	 * @ordered
	 */
	protected static final int TIME_SLOTS_REQUIRED_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getTimeSlotsRequired() <em>Time Slots Required</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimeSlotsRequired()
	 * @generated
	 * @ordered
	 */
	protected int timeSlotsRequired = TIME_SLOTS_REQUIRED_EDEFAULT;

	/**
	 * The cached value of the '{@link #getProductsRequired() <em>Products Required</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProductsRequired()
	 * @generated
	 * @ordered
	 */
	protected EList productsRequired;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ServiceImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return ClinicPackage.Literals.SERVICE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.SERVICE__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getBaseCost() {
		return baseCost;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBaseCost(int newBaseCost) {
		int oldBaseCost = baseCost;
		baseCost = newBaseCost;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.SERVICE__BASE_COST, oldBaseCost, baseCost));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getTimeSlotsRequired() {
		return timeSlotsRequired;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTimeSlotsRequired(int newTimeSlotsRequired) {
		int oldTimeSlotsRequired = timeSlotsRequired;
		timeSlotsRequired = newTimeSlotsRequired;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.SERVICE__TIME_SLOTS_REQUIRED, oldTimeSlotsRequired, timeSlotsRequired));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getProductsRequired() {
		if (productsRequired == null) {
			productsRequired = new EObjectContainmentEList(Product.class, this, ClinicPackage.SERVICE__PRODUCTS_REQUIRED);
		}
		return productsRequired;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getCost() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getTime() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ClinicPackage.SERVICE__PRODUCTS_REQUIRED:
				return ((InternalEList)getProductsRequired()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ClinicPackage.SERVICE__NAME:
				return getName();
			case ClinicPackage.SERVICE__BASE_COST:
				return new Integer(getBaseCost());
			case ClinicPackage.SERVICE__TIME_SLOTS_REQUIRED:
				return new Integer(getTimeSlotsRequired());
			case ClinicPackage.SERVICE__PRODUCTS_REQUIRED:
				return getProductsRequired();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ClinicPackage.SERVICE__NAME:
				setName((String)newValue);
				return;
			case ClinicPackage.SERVICE__BASE_COST:
				setBaseCost(((Integer)newValue).intValue());
				return;
			case ClinicPackage.SERVICE__TIME_SLOTS_REQUIRED:
				setTimeSlotsRequired(((Integer)newValue).intValue());
				return;
			case ClinicPackage.SERVICE__PRODUCTS_REQUIRED:
				getProductsRequired().clear();
				getProductsRequired().addAll((Collection)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
			case ClinicPackage.SERVICE__NAME:
				setName(NAME_EDEFAULT);
				return;
			case ClinicPackage.SERVICE__BASE_COST:
				setBaseCost(BASE_COST_EDEFAULT);
				return;
			case ClinicPackage.SERVICE__TIME_SLOTS_REQUIRED:
				setTimeSlotsRequired(TIME_SLOTS_REQUIRED_EDEFAULT);
				return;
			case ClinicPackage.SERVICE__PRODUCTS_REQUIRED:
				getProductsRequired().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ClinicPackage.SERVICE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case ClinicPackage.SERVICE__BASE_COST:
				return baseCost != BASE_COST_EDEFAULT;
			case ClinicPackage.SERVICE__TIME_SLOTS_REQUIRED:
				return timeSlotsRequired != TIME_SLOTS_REQUIRED_EDEFAULT;
			case ClinicPackage.SERVICE__PRODUCTS_REQUIRED:
				return productsRequired != null && !productsRequired.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", baseCost: ");
		result.append(baseCost);
		result.append(", timeSlotsRequired: ");
		result.append(timeSlotsRequired);
		result.append(')');
		return result.toString();
	}

} //ServiceImpl
